package river_city_ransom.tests;

import java.util.ArrayList;
import java.util.List;

import river_city_ransom.contracts.Dimensions_C;
import river_city_ransom.contracts.MoteurJeu_C;
import river_city_ransom.contracts.Terrain_C;
import river_city_ransom.implementations.Bloc_I;
import river_city_ransom.implementations.Dimensions_I;
import river_city_ransom.implementations.MoteurJeu_I;
import river_city_ransom.implementations.Objet_I;
import river_city_ransom.implementations.Position_I;
import river_city_ransom.implementations.Terrain_I;
import river_city_ransom.services.Bloc;
import river_city_ransom.services.Dimensions;
import river_city_ransom.services.MoteurJeu;
import river_city_ransom.services.Objet;
import river_city_ransom.services.Terrain;
import river_city_ransom.types.BlocType;
import river_city_ransom.types.ObjetNom;
import exceptions.ComposantError;
import junit.framework.TestCase;

public class MoteurJeu_T extends TestCase{
	public void test_init_ok() {
		try {
			Dimensions d = new Dimensions_C(new Dimensions_I(50, 50, 30));
			List<Bloc> lb = new ArrayList<>();
			List<Objet> lo = new ArrayList<>();
			lo.add(new  Objet_I(ObjetNom.CHAINE_DE_VELO));
			for(int i = 0; i < 50; i++){
				for(int j = 0; j < 50; j++){
					lb.add(new Bloc_I(BlocType.VIDE, new Position_I(i, j, 0)));
				}
			}
			Terrain t = new Terrain_C(new Terrain_I(d, lb, lo));
			t.init(d, lb, lo);
			MoteurJeu m = new MoteurJeu_C(new MoteurJeu_I());
			m.init(t);
		}
		catch(ComposantError e) {
			System.err.println("MoteurJeu::test_init_pre_ok\n\t" + e.getMessage());
			fail(e.getMessage());
		}
	}
	
	public void test_init_ko() {
		try {
			Dimensions d = new Dimensions_C(new Dimensions_I(50, 50, 30));
			List<Bloc> lb = new ArrayList<>();
			List<Objet> lo = new ArrayList<>();
			lo.add(new  Objet_I(ObjetNom.CHAINE_DE_VELO));
			for(int i = 0; i < 50; i++){
				for(int j = 0; j < 50; j++){
					lb.add(new Bloc_I(BlocType.VIDE, new Position_I(i, j, 0)));
				}
			}
			Terrain t = new Terrain_C(new Terrain_I(d, lb, lo));
			t.init(d, lb, lo);
			MoteurJeu m = new MoteurJeu_C(new MoteurJeu_I());
			m.init(null);
			System.err.println("MoteurJeu::test_init_pre_ko\n\t");
			fail("Exception non levée.");
		}
		catch(ComposantError e) {
		}
	}
}
